package edu.bit.water.controller;

import edu.bit.water.entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

import edu.bit.water.service.WasteWaterEvaService;


/**
 * 这里对应数据库中Meta_assessment_indicator表的controller
 * 对应企业管理指标
 * @Author： Page
 */
@Controller
@RequestMapping("/wastewatereva")
public class WasteWaterEvaController {

    @Autowired
    private WasteWaterEvaService WasteWaterEvaService = new WasteWaterEvaService();

    //表一的选择
    @ResponseBody
    @RequestMapping(value = "/select", method=RequestMethod.GET)
    public Map<String, Object>selectWasteWaterEva() {
        Map<String, Object> result = new HashMap<>();
        List<WasteWaterEva> list = WasteWaterEvaService.selectWasteWaterEva();
        result.put("rows", list);
        return result;
    }
    //表二的选择
    @ResponseBody
    @RequestMapping(value = "/table2_select", method=RequestMethod.GET)
    public Map<String, Object>table2_selectWasteWaterEva() {
        Map<String, Object> result = new HashMap<>();
        List<WasteWaterEva2> list = WasteWaterEvaService.selectWasteWaterEva2();
        result.put("rows", list);
        return result;
    }


    @ResponseBody
    @RequestMapping("/insert")
    public Map<String, Object> insertWasteWaterEva(WasteWaterEva WasteWaterEva) {
        //WasteWaterEva.showContent();
        WasteWaterEva.dateChange();
        return WasteWaterEvaService.insertWasteWaterEva(WasteWaterEva);
    }

    @ResponseBody
    @RequestMapping("/table2_insert")
    public Map<String, Object> insertWasteWaterEva2(WasteWaterEva2 WasteWaterEva2) {
        //WasteWaterEva.showContent();
        WasteWaterEva2.dateChange();
        return WasteWaterEvaService.insertWasteWaterEva2(WasteWaterEva2);
    }

    /**
     * 删除metaStandard
     * author Page
     */
    @ResponseBody
    @RequestMapping("/delete")
    public Map<String, Object> deleteWasteWaterEva(@RequestBody List<String>WasteWaterEvas) {
        return WasteWaterEvaService.deleteWasteWaterEva(WasteWaterEvas);
    }

    @ResponseBody
    @RequestMapping("/table2delete")
    public Map<String, Object> deleteWasteWaterEva2(@RequestBody List<String>WasteWaterEvas2) {
        return WasteWaterEvaService.deleteWasteWaterEva2(WasteWaterEvas2);
    }

    @ResponseBody
    @RequestMapping("/update")
    public Map<String, Object> updateMetaStandard(WasteWaterEva WasteWaterEva) {
        WasteWaterEva.dateChange();
        Map<String, Object> result = WasteWaterEvaService.updateWasteWaterEva(WasteWaterEva);
        return result;
    }

    @ResponseBody
    @RequestMapping("/table2update")
    public Map<String, Object> updateMetaStandard2(WasteWaterEva2 WasteWaterEva2) {
        WasteWaterEva2.dateChange();
        Map<String, Object> result = WasteWaterEvaService.updateWasteWaterEva2(WasteWaterEva2);
        return result;
    }


    @RequestMapping("/getEvaBasis")
    @ResponseBody
    public Map<String, Object> getBasis(){
        Map<String, Object> modelMap = new HashMap<>();
        List<MetaDischarge> list = WasteWaterEvaService.getBasis();
        modelMap.put("status", "success");
        modelMap.put("rows", list);
        return modelMap;
    }

    @RequestMapping("/getEvaScope")
    @ResponseBody
    public Map<String, Object> getScope(){
        Map<String, Object> modelMap = new HashMap<>();
        List<MetaDischargeMaxPermission> list = WasteWaterEvaService.getScope();
        modelMap.put("status", "success");
        modelMap.put("rows", list);
        return modelMap;
    }

    @RequestMapping("/getEvaLevel")
    @ResponseBody
    public Map<String, Object> getLevel(){
        Map<String, Object> modelMap = new HashMap<>();
        List<MetaDischargeMaxPermission> list = WasteWaterEvaService.getLevel();
        modelMap.put("status", "success");
        modelMap.put("rows", list);
        return modelMap;
    }


    /**
     * 查询meta_water_saving中的标准状态
     * @return meta_water_saving中的所有记录
     */
    @RequestMapping("/get_standard_status")
    @ResponseBody
    public Map<String, Object> getStandardStatus(){
        Map<String, Object> modelMap = new HashMap<>();
        List<MetaDischarge> list = WasteWaterEvaService.getStandardStatus();
        modelMap.put("status", "success");
        modelMap.put("rows", list);
        return modelMap;
    }
}
